package com.example.coursehub.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import java.time.Instant;
import java.time.LocalDateTime;

@Getter
@Setter
@Entity
@Table(name = "exercise", schema = "courseHub")
public class Exercise {
    @Id
    @Column(name = "exercise_id", nullable = false, length = 100)
    private String exerciseId;

    @Column(name = "exercise_name", nullable = false, length = 100)
    private String exerciseName;

    @Column(name = "exercise_deadline", nullable = false)
    private LocalDateTime exerciseDeadline;

    @Column(name = "exercise_start_time", nullable = false)
    private LocalDateTime exerciseStartTime;

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @OnDelete(action = OnDeleteAction.CASCADE)
    @JoinColumn(name = "classes_id", nullable = false)
    private Classes classes;

    @Column(name = "is_multiple_submission", nullable = false)
    private Boolean isMultipleSubmission = false;

    @Column(name = "exercise_score", nullable = false)
    private Integer exerciseScore;
}